package com.after.saas.file.listener;

import com.after.saas.file.domain.vo.ExcelErrorVO;
import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import lombok.Data;

import java.util.ArrayList;
import java.util.List;

/**
 * @Description excel
 * @Classname DefaultReadEventListener
 * @Author hjchen
 * @Version V1.0.0
 * @Since 1.0
 * @Date 2022/11/7 18:17
 */

@Data
public abstract class AbstractReadEventListener<T> extends AnalysisEventListener<T> {


    protected List<T> data = new ArrayList<>();

    protected List<ExcelErrorVO> errorInfo = new ArrayList<>();

    /**
     * 获取类型
     * @Author hjchen
     * @Description
     * @Date 2022/11/7 18:22
     * @Param []
     * @return java.lang.Class
     **/
    public abstract Class supportClass();

    /**
     * excel校验
     * @Author hjchen
     * @Date 2022/11/7 18:22
     * @param date
     * @return void
     **/
    public abstract void checkExcel(List<T> date);

    @Override
    public void doAfterAllAnalysed(AnalysisContext analysisContext) {
        checkExcel(data);
    }

}
